package com.jinmdz.fmis.dao.admin.dao;

import com.jinmdz.fmis.dao.admin.model.furnace.FurnaceEditItem;
import com.jinmdz.fmis.dao.admin.model.furnace.FurnaceListItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

/**
 * 火化炉维护Dao
 *
 * @author LiCongLu
 * @date 2020-03-10 16:41
 */
public interface FurnaceDao {

    /**
     * 查询火化炉列表
     *
     * @param
     * @return
     * @author LiCongLu
     * @date 2020-03-10 16:41
     */
    @Select(" select id,furnace_type_code,furnace_code,furnace_describe,disable_state,sort,remark,version " +
            "  from cremation_furnace where deleted = 0 order by sort")
    ArrayList<FurnaceListItem> listFurnaceList();

    /**
     * 按照主键获取火化炉信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-03-10 16:42
     */
    @Select(" select id,furnace_type_code,furnace_code,furnace_describe,disable_state,sort,remark,version " +
            "  from cremation_furnace where id = #{id} and deleted = 0 limit 1")
    FurnaceEditItem getFurnaceEditById(@Param("id") Integer id);

    /**
     * 按照火化炉编码查询非当前火化炉信息主键
     *
     * @param furnaceId   当前火化炉主键
     * @param furnaceCode 火化炉编码
     * @return
     * @author LiCongLu
     * @date 2020-03-10 16:42
     */
    @Select(" select id from cremation_furnace where id != IFNULL(#{furnaceId},0) and furnace_code = #{furnaceCode} and deleted = 0 limit 1 ")
    @ResultType(Integer.class)
    Integer getFurnaceIdByFurnaceCode(@Param("furnaceId") Integer furnaceId, @Param("furnaceCode") String furnaceCode);
}
